{include file="common/_meta" /}
<title>修改</title>
<meta name="keywords" content="李志立，lizhilimaster@163.com">
<meta name="description" content="李志立，lizhilimaster@163.com">
<style type="text/css">
	#container{
		/*地图(容器)显示大小*/
		width:100%;
		height:400px;
	}
</style>
<!--引入Javascript API GL，参数说明参见下文-->
<script src="https://map.qq.com/api/gljs?v=1.exp&libraries=service&key={$key}"></script>
<script>
	//地图初始化函数，本例取名为init，开发者可根据实际情况定义
	function initMap() {
		setTimeout(()=>{
			//定义地图中心点坐标
			var center = new TMap.LatLng(38.0435,114.512313) //默认定位到石家庄了

			//定义map变量，调用 TMap.Map() 构造函数创建地图
			var map = new TMap.Map(document.getElementById('container'), {
				center: center,//设置地图中心点坐标
				zoom: 12,   //设置地图缩放级别
			});

			//初始化marker图层
			var markerLayer = new TMap.MultiMarker({
				id: 'marker-layer',
				map: map
			});
            {if $data.lat}
            markerLayer.setGeometries([{
                position:  new TMap.LatLng(Number({$data.lat}), Number({$data.lon}))
            }])
            {/if}
			//监听点击事件添加marker
			map.on("click", (evt) => {
				// markerLayer.add({
				// 	position: evt.latLng
				// });
				let jing=evt.latLng
				document.getElementById('lat').value=jing.lat
				document.getElementById('lon').value=jing.lng
				markerLayer.setGeometries([{
					position: jing
				}])
				var geocoder = new TMap.service.Geocoder();
				var location = new TMap.LatLng(Number(jing.lat), Number(jing.lng));
				geocoder.getAddress({ location: location }) // 将给定的坐标位置转换为地址
						.then((result) => {
							document.getElementById('address_name').value=result.result.formatted_addresses.recommend
							document.getElementById('sheng').value=result.result.address_component.province
							document.getElementById('shi').value=result.result.address_component.city
							document.getElementById('xian').value=result.result.address_component.district
							document.getElementById('address').value = result.result.address;
							document.getElementById('sheng_html').value = result.result.address_component.province+'-'+result.result.address_component.city+'-'+result.result.address_component.district
						});
			});
		},800)
	}




</script>
</head>
<body onload="initMap()">
<div class="page-container">
    <form action="" method="post" enctype="multipart/form-data" class="form form-horizontal" id="form-category-add">
        <div id="tab-category" class="HuiTab">
            <div class="tabCon">
                <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>标题 ：</label>
                    <div class="formControls col-xs-9 col-sm-9">
                        <input type="text" class="input-text" value="{$data.title}" placeholder="" id="title" name="title">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>图片：</label>
                    <div class="formControls col-xs-9 col-sm-9">
                        <div class="uploader-thum-container">
                            <a href="javascript:void();" class="btn btn-primary radius"><i class="icon Hui-iconfont">&#xe642;</i>
                                浏览文件</a>
                            <input type="file" class="input-file" onchange='onpic(this)' name="img" value=""
                                   accept='image/*' style="font-size: 20px;left:0;"/><span calss="sp"></span>
                        </div>
                        <div style="margin-top: 15px;">
                            {if condition="$data.img != ''"}
                            <img src="{$data.img}" height="60" style="margin: 20px;" />
                            {else /}
                            <div>暂无缩率图</div>
                            {/if}
                        </div>
                    </div>
                </div>
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2">简介：</label>
					<div class="formControls col-xs-9 col-sm-9">
								<textarea name="desc" cols="" rows="" id="desc" class="textarea"
										  placeholder="说点什么...最少输入10个字符" datatype="*10-200"
										  dragonfly="true" nullmsg="备注不能为空！" onKeyUp="textlength()">{$data.desc}</textarea>
						<p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>姓名 ：</label>
					<div class="formControls col-xs-9 col-sm-9">
						<input type="text" class="input-text" value="{$data.name}" placeholder="" id="name" name="name">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>电话号码 ：</label>
					<div class="formControls col-xs-9 col-sm-9">
						<input type="text" class="input-text" value="{$data.phone}" placeholder="" id="phone" name="phone">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2">是否冷藏 ：</label>
					<div class="formControls col-xs-9 col-sm-9 skin-minimal">
						<div class="radio-box">
							<label><input type="radio" {if $data.is_dong==1}checked{/if} name="is_dong" value="1">支持冷藏</label>
						</div>
						<div class="radio-box">
							<label><input type="radio" {if $data.is_dong==0}checked{/if} name="is_dong" value="0">不支持冷藏</label>
						</div>
					</div>
				</div>
				
				
				<div class="row cl">
				    <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span> 状态 ：</label>
				    <div class="formControls col-xs-9 col-sm-9 skin-minimal">
				        <div class="radio-box">
				            <label ><input type="radio"  name="lei" value="1" {if $data.lei==1}checked{/if}>通过</label>
				        </div>
						<div class="radio-box">
						    <label ><input type="radio"  name="lei" value="0" {if $data.lei==0}checked{/if}> 审核中</label>
						</div>
						<div class="radio-box">
						    <label ><input type="radio"  name="lei" value="2" {if $data.lei==2}checked{/if}> 驳回</label>
						</div>
				    </div>
				</div>
				<div class="row cl">
				    <label class="form-label col-xs-3 col-sm-2">身份证号 ：</label>
				    <div class="formControls col-xs-9 col-sm-9">
				        <input type="text" class="input-text" value="{$data.idNo}" placeholder="请输入身份号" name="idNo">
				    </div>
				</div>
				<div class="row cl">
				    <label class="form-label col-xs-3 col-sm-2">身份证图片 ：</label>
				    <div class="formControls col-xs-4 col-sm-4">
						{if $data.idCard1}
				        <img src="{$data.idCard1}" style="width: 80%;" alt="">
						{else /}
						暂无数据
						{/if}
				    </div>
					<div class="formControls col-xs-4 col-sm-4">
					     {if $data.idCard2}
					     <img src="{$data.idCard2}" style="width: 80%;" alt="">
					     {else /}
					     暂无数据
					     {/if}
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span> 上级渠道：</label>
					<div class="formControls col-xs-9 col-sm-9"> <span class="select-box">
							<select name="fid"  class="select">
								<option value=0>未选择渠道</option>
								{volist name="qudao" id="vo"}
								<option {if $vo.id==$data.fid}selected{/if} value="{$vo.id}">{$vo.nickName ?: $vo.phone}</option>
								{/volist}
							</select>
						</span> </div>
				</div>
				
				<div class="row cl">
				    <label class="form-label col-xs-3 col-sm-2">地区 ：</label>
				    <div class="formControls col-xs-3 col-sm-3">
						
				        <input type="text" readonly class="input-text" value="<?php echo explode('-',$data['sheng_html'])[0] ?? '';?>" placeholder="点击地图" id="sheng" name="sheng">
				    </div>
					<div class="formControls col-xs-3 col-sm-3">
					    <input type="text" readonly class="input-text" value="<?php echo explode('-',$data['sheng_html'])[1] ?? '';?>" placeholder="点击地图" id="shi" name="shi">
					</div>
					<div class="formControls col-xs-3 col-sm-3">
					    <input type="text" readonly class="input-text" value="<?php echo explode('-',$data['sheng_html'])[2] ?? '';?>" placeholder="点击地图" id="xian" name="xian">
					</div>
					 <input type="hidden" class="input-text" value="" placeholder="" id="sheng_html" name="sheng_html">
				</div>
				
				<div class="row cl">
				    <label class="form-label col-xs-3 col-sm-2">地址名称 ：</label>
				    <div class="formControls col-xs-9 col-sm-9">
				        <input type="text" readonly class="input-text" value="{$data.address_name}" placeholder="点击地图" id="address_name" name="address_name">
				    </div>
				</div>
				
                <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>地址 ：</label>
                    <div class="formControls col-xs-9 col-sm-9">
                        <input type="text" readonly class="input-text" value="{$data.address}" placeholder="" id="address" name="address">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>经纬度 ：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" readonly class="input-text" value="{$data.lat}" placeholder="点击地图" id="lat" name="lat">
                    </div>
					<div class="formControls col-xs-4 col-sm-4">
						<input type="text" readonly class="input-text" value="{$data.lon}" placeholder="点击地图" id="lon" name="lon">
					</div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-3 col-sm-2">请选择位置 ：</label>
                    <div class="formControls col-xs-9 col-sm-9">
						<div id="container"></div>
                    </div>
                </div>

                <div class="row cl">
                    <div class="col-9 col-offset-2">
                        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<!--_footer 作为公共模版分离出去-->
{include file="common/_footer" /}
<style type="text/css">
    .li123 {
        line-height: 30px;
        background: burlywood;
        display: inline-block;
        vertical-align: middle;
        padding: 0 8px;
    }

    #abtn, .dtbtn {
        color: red;
    }
</style>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#tab-category").Huitab({
            index: 0
        });
        $("input[type=\"submit\"]").on('click', function () {
            let wo = $("#form-category-add").validate({
                rules: {
                    title: {required: true},
                    address: {required: true},
                    lat: {required: true},
                    lon: {required: true},
                    name: {required: true},
                    phone: {required: true},
                }
            });
            if (wo.form()) {
                setTimeout(() => {
                    $("input[type=\"submit\"]").addClass('disabled').attr("disabled", true);
                }, 1000)
                var index = layer.load(1, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });
                // 关闭当前界面
                // var index = parent.layer.getFrameIndex(window.name);
                // parent.layer.close(index);
            }
        });

    });

    function textlength() {
        var nmb = $('#desc').val().length;
        $('.textarea-length').text(nmb);
        if (nmb > 200) {
            $('#desc').css("background-color", "orangered");
        } else {
            $('#desc').css("background-color", "white");
        }
    }

    function onpic(e) {
        $(e).parent().find('span').html(e.files[0].name).addClass('li123');
        //获取当前的值
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
